#!/usr/bin/env python
# coding=utf-8
# @FileName  :test.py
# @Time      :2024/7/8 9:48
# @Author    :jdz
# @description :
import multiprocessing
import time


def worker(interval):
    print(f"Process {multiprocessing.current_process().name} started")
    time.sleep(interval)
    print(f"Process {multiprocessing.current_process().name} ended")


if __name__ == "__main__":
    num_processes = int(input("Enter the number of processes: "))

    processes = []
    for i in range(num_processes):
        p = multiprocessing.Process(target=worker, args=(2,), name=f"Process-{i + 1}")
        processes.append(p)
        p.start()

    for p in processes:
        p.join()

    print("All processes have finished.")
